Enable all XCCDF groups when TP extends a profile#1199
Enable all XCCDF groups when TP extends a profile#1199yuumasato wants to merge 1 commit intoComplianceAsCode:masterfrom
Conversation
Keep track of all XCCDF Groups in the ProfileBundle and always enable them when a TailoredProfile extends a Profile. This ensures that any rule that is enabled has its parent Group enabled as well, ensuring that OpenSCAP can get to the rule that was enbled.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: yuumasato The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
The ProfileBundle ends up looking like this: |
|
🤖 To deploy this PR, run the following command: |
|
@yuumasato: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
| func TailoredProfileToXML(tp *cmpv1alpha1.TailoredProfile, p *cmpv1alpha1.Profile, pb *cmpv1alpha1.ProfileBundle, rules map[string]*cmpv1alpha1.Rule, variables []*cmpv1alpha1.Variable) (string, error) { | ||
| // Extract group IDs from ProfileBundle annotation if this TP extends a profile | ||
| var groupIDs []string | ||
| if p != nil { |
There was a problem hiding this comment.
Should this also check if pb is nil?
| pb.SetAnnotations(annotations) | ||
|
|
||
| // Update the ProfileBundle with the new annotation | ||
| if err := pcfg.Client.Update(context.TODO(), pb); err != nil { |
There was a problem hiding this comment.
Should this be Patch to avoid updating the entire object?
Keep track of all XCCDF Groups in the ProfileBundle and always enable them when a TailoredProfile extends a Profile.
This ensures that any rule that is enabled has its parent Group enabled as well, ensuring that OpenSCAP can get to the rule that was enbled.
If a TailoredProfile enables a rule that is not part of an XCCDF group enabled by the extended profile, the rule won't be enabled at all by OpenSCAP. This is because data stream traversal will stop at the disabled group.
Issue discovered when testing ComplianceAsCode/content#14665